/*
https://www.npmjs.com/package/node-ssh
node-ssh是一个基于ssh2的轻量级npm包，主要用于ssh连接服务器、上传文件、执行命令。
*/
import {NodeSSH} from 'node-ssh'
import fs from 'fs'

const ssh = new NodeSSH()
ssh.connect({
  host: '47.108.228.21',
  port: 22,
  username: 'root',
  password: 'root123+-',
}).then(async () => {

  ssh.putFile('./admin.zip', '/app/admin.zip').then(async function () {
    if (fs.existsSync('./admin.zip')) {
      fs.unlinkSync('./admin.zip')
      await ssh.execCommand('rm -rIf /App/admin')
      await ssh.execCommand('unzip -o /App/admin.zip -d /App')
      await ssh.execCommand('rm -rIf /App/admin.zip')
      console.log('上传完成')
    }
  })
})





